<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="姓`名">
              <a-input placeholder="请输入姓名" v-model="queryParam.staffName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="10" :lg="11" :md="12" :sm="24">
            <a-form-item label="预计入职时间">
              <j-date placeholder="请选择开始日期" class="query-group-cust" v-model="queryParam.planEntryTime_begin"></j-date>
              <span class="query-group-split-cust"></span>
              <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="queryParam.planEntryTime_end"></j-date>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button v-if="!this.showRecord" @click="showRecordList(true)" type="text" icon="search">查看转正记录</a-button>
      <a-button v-if="this.showRecord" type="primary" icon="download" @click="handleExportXls('已转正导出成员信息')">导出</a-button>
      <a-button v-if="this.showRecord" @click="showRecordList(false)" type="text" icon="double-left">返回</a-button>


    </div>
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a @click="formal(record)">办理转正</a>
        </span>
        <span slot="planFormalTime" slot-scope="text, record">
          {{text}}
          <a @click="formalTime(record)">调整</a>
        </span>
      </a-table>
    </div>

    <satff-modal ref="modalForm" @ok="modalFormOk"></satff-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import SatffModal from './modules/SatffModal'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'

  export default {
    name: 'SatffList',
    showRecord:false,
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      SatffModal
    },
    data () {
      return {
        description: '人事表管理页面',
        queryParam: {
          entryStatus:1
        },
        columns:[],
        // 表头
        columnsFormal: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'姓名',
            align:"center",
            dataIndex: 'staffName'
          },
          {
            title:'部门',
            align:"center",
            dataIndex: 'staffDepartmentIds_dictText'
          },
          {
            title:'职位',
            align:"center",
            dataIndex: 'staffJob'
          },
          {
            title:'员工类型',
            align:"center",
            dataIndex: 'staffType_dictText'
          },

          {
            title:'入职时间',
            align:"center",
            dataIndex: 'entryTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'试用期',
            align:"center",
            dataIndex: 'staffTrialType_dictText'
          },
          {
            title:'计划转正时间',
            align:"center",
            dataIndex: 'planFormalTime',
            scopedSlots: { customRender: 'planFormalTime' },
          },
          {
            title:'实际转正时间',
            align:"center",
            dataIndex: 'realFormalTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        columnsRecord: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'姓名',
            align:"center",
            width:120,
            dataIndex: 'staffName'
          },
          {
            title:'入职时间',
            align:"center",
            dataIndex: 'planEntryTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'转正时间',
            align:"center",
            dataIndex: 'realFormalTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'转正时部门',
            align:"center",
            dataIndex: 'staffDepartmentIds_dictText'
          },
          {
            title:'转正时职位',
            align:"center",
            dataIndex: 'staffJob'
          },
        ],


        url: {
          list: "/satff/satff/list",
          exportXlsUrl: "/satff/satff/exportFormalXls",
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
      this.columns = this.columnsFormal;
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    mounted(){
      console.log(this.$route.query);
    },
    methods: {
      showRecordList(val) {
        this.showRecord = val;
        if (val) {
          this.columns = this.columnsRecord;
          this.queryParam.entryStatus_gt = 1;
          this.queryParam.entryStatus = null;
        }else{
          this.columns = this.columnsFormal;
          this.queryParam.entryStatus = 1;
          this.queryParam.entryStatus_gt = null;
        }
        this.loadData(1);
      },
      initDictConfig(){
      },
      formal (record) {
        this.$refs.modalForm.formal(record);
        this.$refs.modalForm.title = "办理转正";
        this.$refs.modalForm.disableSubmit = false;
      },
      formalTime(record) {
        this.$refs.modalForm.formalTime(record);
        this.$refs.modalForm.title = "调整计划转正时间";
        this.$refs.modalForm.disableSubmit = false;
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'staffName',text:'姓名',dictCode:''})
        fieldList.push({type:'string',value:'staffPhone',text:'手机号',dictCode:''})
        fieldList.push({type:'int',value:'staffTrialType',text:'试用类型',dictCode:'staff_trial_type'})
        fieldList.push({type:'int',value:'staffType',text:'员工类型',dictCode:'staff_type'})
        fieldList.push({type:'string',value:'staffWorkAddress',text:'办公地点',dictCode:''})
        fieldList.push({type:'string',value:'staffJob',text:'职位',dictCode:''})
        fieldList.push({type:'int',value:'staffLeader',text:'直接主管',dictCode:''})
        fieldList.push({type:'sel_depart',value:'staffDepartmentIds',text:'部门'})
        fieldList.push({type:'date',value:'planEntryTime',text:'预计入职时间'})
        fieldList.push({type:'date',value:'planFormalTime',text:'预计转正时间'})
        fieldList.push({type:'date',value:'realFormalTime',text:'实际转正时间'})
        fieldList.push({type:'int',value:'formalType',text:'入职时员工类型',dictCode:'formal_type'})
        fieldList.push({type:'int',value:'formalStatus',text:'入职时员工状态',dictCode:'formal_status'})
        fieldList.push({type:'date',value:'entryTime',text:'入职时间'})
        fieldList.push({type:'int',value:'entryStatus',text:'入职状态',dictCode:'entry_status'})
        fieldList.push({type:'int',value:'entryOrigin',text:'来源'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>